package com.base.social.auth.factory;

import com.base.social.auth.request.AuthWeChatOpen;
import com.base.social.cache.AuthStateCache;
import com.base.social.config.AuthConfig;
import com.base.social.auth.Auth;
import com.base.social.auth.AuthFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

public class WechatOpenAuthFactory implements AuthFactory {

    /**
     * 客户端id：对应各平台的appKey
     */
    private String clientId;

    /**
     * 客户端Secret：对应各平台的appSecret
     */
    private String clientSecret;

    /**
     * 登录成功后的回调地址
     */
    private String redirectUri;

    /**
     * 微信响应类型 默认code
     */
    private String responseType;

    /**
     * 微信授权作用域
     */
    private String scope;

    private static class Holder{
        private static final WechatOpenAuthFactory INSTANCE = new WechatOpenAuthFactory();
    }

    //实例化
    public static WechatOpenAuthFactory build(){
        return Holder.INSTANCE;
    }


    @Override
    public Auth instance(AuthConfig authConfig, AuthStateCache authStateCache) {
        if (authStateCache != null) {
            return new AuthWeChatOpen(authConfig, authStateCache);
        }
        return new AuthWeChatOpen(authConfig);
    }


}
